#!/usr/bin/env python
#
#       
#       Copyright 2008 karthikeyan S.<kaarthikeyapreyan@gmail.com>
#       
#       This program is free software; you can redistribute it and/or modify
#       it under the terms of the GNU General Public License as published by
#       the Free Software Foundation; either version 2 of the License, or
#       (at your option) any later version.
#       
#       This program is distributed in the hope that it will be useful,
#       but WITHOUT ANY WARRANTY; without even the implied warranty of
#       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#       GNU General Public License for more details.
#       
#       You should have received a copy of the GNU General Public License
#       along with this program; if not, write to the Free Software
#       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#       MA 02110-1301, USA.

from types import *
from write import *
import sys, inspect, HandleArgs


def describeInMod(modulename,write=0):
	"""
	List of modules that are imported for the current module
	and which are present in the module
	"""
	if write:
		generatefile().writefile("\t\tModule: %s\n" % modulename.__name__)
	else :
		print "\t\tModule: %s" % modulename.__name__	

def describeUnknowns(bname,write=0):
	"""
  	Describe the type which Could not be detrmined by PyTestgenerator
  	"""
   	if write :
		generatefile().writefile("\t\tUndefined Type: %s\n" %bname)
	else :
		print "\t\tUndefined Type: %s" %bname

def describeVars(vname,attr,write=0):
	"""
   	All the variables Come here
   	"""

   	if type(attr) is StringType :
      		case = "String"
   	elif type(attr) is IntType :
      		case = "Integer"
   	elif type(attr) is ListType :
      		case = "List"
   	elif type(attr) is NoneType :
      		case = "None"
   	else :
      		print "Unexpected variable type encountered: %s " %type(attr)
      
   	if not write:
      		print "\t\tVariable: %s \tType %s"%(vname,case) 
   	elif write:
      		generatefile().writefile("\t\tVariable: %s\tType %s\n"%(vname,case))

def describeBuiltins(bname,attr,write=0):
	"""
  	Describe the builin classes, functions and variables
  	"""

	if type(attr) is BuiltinFunctionType and not write:
		print "Builtin Function: %s"%bname
	elif type(attr) is BuiltinFunctionType and write:
		generatefile().writefile("Builtin Function: %s\n"%bname)

	if type(attr) is BuiltinMethodType and not write:
		print "Builtin Method: %s"%bname
	elif type(attr) is BuiltinMethodType and write:
		generatefile().writefile( "Builtin Method: %s\n"%bname)

